#include<bits/stdc++.h>
using namespace std;

int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
	int yy, mm, dd;
	cin>>yy>>mm>>dd;
	if(yy % 4 == 0 && yy % 100 || yy % 400 == 0)
		d[2] = 29;
	int num = 0;
	for(int i = 1;i < mm;i++)
	{
		num += d[i];
	}
	num += dd;
	cout<<num;
    return 0;
}

